package com.ponhu.ea2.stockcenter.provider.service.entity.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ponhu.ea2.common.basic.util.time.DateUtils;
import com.ponhu.ea2.stockcenter.dto.OrderInfoDTO;
import com.ponhu.ea2.stockcenter.enums.DefinedSystem;
import com.ponhu.ea2.stockcenter.enums.ExchangeActionTypeEnum;
import com.ponhu.ea2.stockcenter.provider.constants.CommonConstant;
import com.ponhu.ea2.stockcenter.provider.entity.StockInventoryDocOccupy;
import com.ponhu.ea2.stockcenter.provider.mapper.StockInventoryDocOccupyMapper;
import com.ponhu.ea2.stockcenter.provider.service.entity.StockInventoryDocOccupyService;
import com.ponhu.ea2.stockcenter.provider.support.enums.DocOccupyStatusEnum;
import com.ponhu.ea2.stockcenter.provider.support.enums.DocOccupyTransferStatusEnum;
import com.ponhu.ea2.stockcenter.provider.support.enums.StockChangeInnerEventEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 销售库存单据占用表服务实现类
 */
@Service
public class StockInventoryDocOccupyServiceImpl
        extends ServiceImpl<StockInventoryDocOccupyMapper, StockInventoryDocOccupy>
        implements StockInventoryDocOccupyService {

    @Override
    public List<StockInventoryDocOccupy> getPlacedDocRecordList(List<String> inventoryCodeList) {
        if (CollectionUtils.isEmpty(inventoryCodeList))
            return null;

        //获取"已下单"状态单据记录列表(已下单状态)
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED)
                        .in(StockInventoryDocOccupy::getInventoryCode, inventoryCodeList)
        );
    }

    @Override
    public List<StockInventoryDocOccupy> getPlacedDocRecordList(String docNo) {
        if (StringUtils.isBlank(docNo))
            return null;

        //获取单据占用库存记录(已下单状态)
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .eq(StockInventoryDocOccupy::getDocNo, docNo)
                        .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED)
        );
    }

    @Override
    public List<StockInventoryDocOccupy> getDocRecordList(String docNo) {
        if (StringUtils.isBlank(docNo))
            return null;

        //获取单据占用库存记录(已下单状态)
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .eq(StockInventoryDocOccupy::getDocNo, docNo)
        );
    }

    @Override
    public List<StockInventoryDocOccupy> getDocRecordList(String docNo, List<String> inventoryCodes) {
        if (StringUtils.isBlank(docNo)) return null;

        LambdaQueryWrapper<StockInventoryDocOccupy> queryWrapper = Wrappers
                .lambdaQuery(StockInventoryDocOccupy.class)
                .eq(StockInventoryDocOccupy::getDocNo, docNo);
        if (CollectionUtils.isNotEmpty(inventoryCodes))
            queryWrapper.in(StockInventoryDocOccupy::getInventoryCode, inventoryCodes);

        return list(queryWrapper);
    }

    @Override
    public List<StockInventoryDocOccupy> getDocOccupyRecord(String docNo) {
        if (StringUtils.isBlank(docNo))
            return null;

        //获取单据占用库存记录(已下单状态)
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .eq(StockInventoryDocOccupy::getDocNo, docNo)
                        .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.YES)
                        .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED)
        );
    }

    @Override
    public List<StockInventoryDocOccupy> getCanceledDocRecordList(String docNo) {
        if (StringUtils.isBlank(docNo))
            return null;

        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .eq(StockInventoryDocOccupy::getDocNo, docNo)
                        .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.CANCELED)
        );
    }

    @Override
    public List<StockInventoryDocOccupy> getAllDocOccupyRecord(String docNo) {
        if (StringUtils.isBlank(docNo))
            return null;

        //获取单据占用库存记录(所有状态)
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .select(StockInventoryDocOccupy::getDocNo,
                                StockInventoryDocOccupy::getInventoryCode,
                                StockInventoryDocOccupy::getDocType,
                                StockInventoryDocOccupy::getUsedNum)
                        .eq(StockInventoryDocOccupy::getDocNo, docNo)
                        .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.YES)
        );
    }

    @Override
    public List<StockInventoryDocOccupy> getAllDocOccupyRecord(List<String> inventoryCodeList) {
        if (CollectionUtils.isEmpty(inventoryCodeList))
            return null;

        //获取单据占用库存记录(所有状态)
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .select(StockInventoryDocOccupy::getDocNo,
                                StockInventoryDocOccupy::getInventoryCode,
                                StockInventoryDocOccupy::getDocType,
                                StockInventoryDocOccupy::getUsedNum)
                        .in(StockInventoryDocOccupy::getInventoryCode, inventoryCodeList)
                        .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.YES)
        );
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean cancelDocOccupy(String docNo, StockChangeInnerEventEnum stockChangeInnerEventEnum) {
        return cancelDocOccupy(docNo, stockChangeInnerEventEnum.getCode(), stockChangeInnerEventEnum.getName());
    }
    private boolean cancelDocOccupy(String docNo, Integer code,  String msg) {
        if (StringUtils.isBlank(docNo)) {
            return false;
        }

        String remark = getNewDocRecordRemark(code, msg, DocOccupyStatusEnum.CANCELED.getCode(), CommonConstant.YES_OR_NO.NO);

        //取消单据占用销售层库存数(取消销售订单)
        LambdaUpdateWrapper<StockInventoryDocOccupy> updateWrapper = Wrappers.lambdaUpdate(StockInventoryDocOccupy.class)
                .set(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.NO)
                .set(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.CANCELED)
                .setSql("remark = concat('" + remark + "', remark)")
                .eq(StockInventoryDocOccupy::getDocNo, docNo)
                .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED);

        return this.update(updateWrapper);
    }


    @Transactional(rollbackFor = {Exception.class})
    @Override
    public boolean releaseDocOccupy(String docNo, ExchangeActionTypeEnum exchangeActionTypeEnum, StockChangeInnerEventEnum stockChangeInnerEventEnum) {
        if(stockChangeInnerEventEnum != null)
            return releaseDocOccupy(docNo, stockChangeInnerEventEnum.getCode(), stockChangeInnerEventEnum.getName());
        return releaseDocOccupy(docNo, exchangeActionTypeEnum.getCode(), exchangeActionTypeEnum.getName());
    }

    private boolean releaseDocOccupy(String docNo, Integer code, String msg) {
        if (StringUtils.isBlank(docNo)) {
            return false;
        }

        String remark = getNewDocRecordRemark(code, msg, CommonConstant.YES_OR_NO.NO,
                DocOccupyTransferStatusEnum.TRANSFER_APPLIED_AND_NO_OUT.getCode());

        //释放单据占用销售层库存数(调拨申请时同时调用销售层释放)
        LambdaUpdateWrapper<StockInventoryDocOccupy> updateWrapper = Wrappers.lambdaUpdate(StockInventoryDocOccupy.class)
                .set(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.NO)
                .set(StockInventoryDocOccupy::getDocTransferStatus, CommonConstant.DOC_TRANSFER_STATUS.TRANSFER_APPLIED_AND_NO_OUT)
                .setSql("remark = concat('" + remark + "', remark)")
                .eq(StockInventoryDocOccupy::getDocNo, docNo)
                .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.YES)
                .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED);

        return this.update(updateWrapper);
    }

    @Override
    public List<StockInventoryDocOccupy> getPlacedAndNoOccupyDocRecord(String docNo) {
        if (StringUtils.isBlank(docNo))
            return null;

        //获取"已下单"状态并且"未占用"的单据记录
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .eq(StockInventoryDocOccupy::getDocNo, docNo)
                        .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.NO)
                        .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED)
        );
    }

    /**
     * 获取"已下单"状态并且"已占用"且"未调拨申请并且未出可售仓"的单据记录
     *
     * @param docNo
     * @return
     */
    public List<StockInventoryDocOccupy> getPlacedAndOccupyAndNoTransferNoOutDocRecord(String docNo) {
        if (StringUtils.isBlank(docNo))
            return null;

        //获取"已下单"状态并且"已占用"且"未调拨申请并且未出可售仓"的单据记录
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .eq(StockInventoryDocOccupy::getDocNo, docNo)
                        .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.YES)
                        .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED)
                        .eq((StockInventoryDocOccupy::getDocTransferStatus), CommonConstant.DOC_TRANSFER_STATUS.NO_TRANSFER_APPLY_AND_NO_OUT));
    }

    @Transactional(rollbackFor = {Exception.class})
    @Override
    public boolean takeDocRecordOutOfWarehouseForNoUsed(String docNo, ExchangeActionTypeEnum exchangeActionTypeEnum, StockChangeInnerEventEnum stockChangeInnerEventEnum) {
        if(stockChangeInnerEventEnum != null)
            return takeDocRecordOutOfWarehouseForNoUsed(docNo, stockChangeInnerEventEnum.getCode(), stockChangeInnerEventEnum.getName());
        return takeDocRecordOutOfWarehouseForNoUsed(docNo, exchangeActionTypeEnum.getCode(), exchangeActionTypeEnum.getName());
    }

    private boolean takeDocRecordOutOfWarehouseForNoUsed(String docNo, Integer code, String msg) {
        if (StringUtils.isBlank(docNo)) {
            return false;
        }

        String remark = getNewDocRecordRemark(code, msg, DocOccupyStatusEnum.OUTED.getCode());

        //将单据记录状态更新为"已出库"
        LambdaUpdateWrapper<StockInventoryDocOccupy> updateWrapper = Wrappers.lambdaUpdate(StockInventoryDocOccupy.class)
                .set(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.OUTED)
                .setSql("remark = concat('" + remark + "', remark)")
                .eq(StockInventoryDocOccupy::getDocNo, docNo)
                .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.NO)
                .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED);

        return this.update(updateWrapper);
    }

    /**
     * 将单据记录状态更新为"已出库"(针对已下单、已占用，销售出库直接出可售仓)
     *
     * @param docNo
     * @return
     */
    @Transactional(rollbackFor = {Exception.class})
    @Override
    public boolean takeDocRecordOutOfWarehouseForUsed(String docNo, ExchangeActionTypeEnum exchangeActionTypeEnum, StockChangeInnerEventEnum stockChangeInnerEventEnum) {
        if(stockChangeInnerEventEnum != null)
            return takeDocRecordOutOfWarehouseForUsed(docNo, stockChangeInnerEventEnum.getCode(), stockChangeInnerEventEnum.getName());
        return takeDocRecordOutOfWarehouseForUsed(docNo, exchangeActionTypeEnum.getCode(), exchangeActionTypeEnum.getName());
    }

    @Override
    public boolean takeDocRecordSalesOut(String docNo, StockChangeInnerEventEnum stockChangeInnerEventEnum) {
        if (StringUtils.isBlank(docNo)) {
            return false;
        }

        String remark = getNewDocRecordRemark(stockChangeInnerEventEnum.getCode(), stockChangeInnerEventEnum.getRemark(), DocOccupyStatusEnum.OUTED.getCode(), CommonConstant.YES_OR_NO.NO);

        //将单据记录状态更新为"已出库",占用状态改为"否"
        LambdaUpdateWrapper<StockInventoryDocOccupy> updateWrapper = Wrappers.lambdaUpdate(StockInventoryDocOccupy.class)
                .set(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.OUTED)
                .set(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.NO)
                .setSql("remark = concat('" + remark + "', remark)")
                .eq(StockInventoryDocOccupy::getDocNo, docNo)
                .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED);

        return this.update(updateWrapper);
    }


    private boolean takeDocRecordOutOfWarehouseForUsed(String docNo, Integer code,  String msg) {
        if (StringUtils.isBlank(docNo)) {
            return false;
        }

        String remark = getNewDocRecordRemark(code, msg, DocOccupyStatusEnum.OUTED.getCode(), CommonConstant.YES_OR_NO.NO);

        //将单据记录状态更新为"已出库",占用状态改为"否"
        LambdaUpdateWrapper<StockInventoryDocOccupy> updateWrapper = Wrappers.lambdaUpdate(StockInventoryDocOccupy.class)
                .set(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.OUTED)
                .set(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.NO)
                .setSql("remark = concat('" + remark + "', remark)")
                .eq(StockInventoryDocOccupy::getDocNo, docNo)
                .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.YES)
                .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED);

        return this.update(updateWrapper);
    }

    @Transactional(rollbackFor = {Exception.class})
    @Override
    public void addSalesOrderOccupyStockRecord(OrderInfoDTO orderInfoDTO, DefinedSystem definedSystem, StockChangeInnerEventEnum stockChangeInnerEventEnum) {

        String remark = getDocRecordRemark(stockChangeInnerEventEnum.getCode(), stockChangeInnerEventEnum.getName());
        //添加销售单占用库存记录
        List<StockInventoryDocOccupy> docOccupyList = orderInfoDTO.getOrderInventoryInfoList().stream().map(i -> {
            StockInventoryDocOccupy inventoryDocOccupy = new StockInventoryDocOccupy();
            inventoryDocOccupy.setDocNo(orderInfoDTO.getDocNo())
                    .setDocType(definedSystem.ordinal())
                    .setInventoryCode(i.getInventoryCode())
                    .setStatus(CommonConstant.DOC_OCCUPY_STATUS.PLACED)
                    .setIsUsed(CommonConstant.YES_OR_NO.YES)
                    .setDocTransferStatus(CommonConstant.DOC_TRANSFER_STATUS.NO_TRANSFER_APPLY_AND_NO_OUT)
                    //保证占用数量永远是正数
                    .setUsedNum(Math.abs(i.getInventoryQuantity()))
                    .setRemark(remark);
            return inventoryDocOccupy;
        }).collect(Collectors.toList());

        this.saveBatch(docOccupyList);
    }

    /**
     * 将订单下的占用记录调拨状态更新为"未调拨申请并且未出可售仓"、"已占用"
     *
     * @param docNo
     * @return
     */
    @Transactional(rollbackFor = {Exception.class})
    @Override
    public boolean changeDocRecordToNoTransferAndNoOutAndUsed(String docNo, ExchangeActionTypeEnum exchangeActionTypeEnum, StockChangeInnerEventEnum stockChangeInnerEventEnum) {
        if(stockChangeInnerEventEnum != null)
            return changeDocRecordToNoTransferAndNoOutAndUsed(docNo, stockChangeInnerEventEnum.getCode(), stockChangeInnerEventEnum.getName());
        return changeDocRecordToNoTransferAndNoOutAndUsed(docNo, exchangeActionTypeEnum.getCode(), exchangeActionTypeEnum.getName());
    }

    private boolean changeDocRecordToNoTransferAndNoOutAndUsed(String docNo, Integer code,  String msg) {
        if (StringUtils.isBlank(docNo)) {
            return false;
        }

        String remark = getNewDocRecordRemark(code, msg, CommonConstant.YES_OR_NO.YES,
                DocOccupyTransferStatusEnum.NO_TRANSFER_APPLY_AND_NO_OUT.getCode());

        //将订单下的占用记录调拨状态更新为"未调拨申请并且未出可售仓"
        LambdaUpdateWrapper<StockInventoryDocOccupy> updateWrapper = Wrappers.lambdaUpdate(StockInventoryDocOccupy.class)
                .set(StockInventoryDocOccupy::getDocTransferStatus, CommonConstant.DOC_TRANSFER_STATUS.NO_TRANSFER_APPLY_AND_NO_OUT)
                .set(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.YES)
                .setSql("remark = concat('" + remark + "', remark)")
                .eq(StockInventoryDocOccupy::getDocNo, docNo);

        return this.update(updateWrapper);
    }

    /**
     * 将订单下的占用记录调拨状态更新为"未调拨申请并且未出可售仓"
     *
     * @param docNo
     * @return
     */
    @Transactional(rollbackFor = {Exception.class})
    @Override
    public boolean changeDocRecordToNoTransferAndNoOut(String docNo, ExchangeActionTypeEnum exchangeActionTypeEnum, StockChangeInnerEventEnum stockChangeInnerEventEnum) {
        if(stockChangeInnerEventEnum != null)
            return changeDocRecordToNoTransferAndNoOut(docNo, stockChangeInnerEventEnum.getCode(), stockChangeInnerEventEnum.getName());
        return changeDocRecordToNoTransferAndNoOut(docNo, exchangeActionTypeEnum.getCode(), exchangeActionTypeEnum.getName());
    }

    private boolean changeDocRecordToNoTransferAndNoOut(String docNo, Integer code, String msg) {
        if (StringUtils.isBlank(docNo)) {
            return false;
        }

        String remark = getNewDocRecordRemark(DocOccupyTransferStatusEnum.NO_TRANSFER_APPLY_AND_NO_OUT.getCode(), code, msg);

        //将订单下的占用记录调拨状态更新为"未调拨申请并且未出可售仓"
        LambdaUpdateWrapper<StockInventoryDocOccupy> updateWrapper = Wrappers.lambdaUpdate(StockInventoryDocOccupy.class)
                .set(StockInventoryDocOccupy::getDocTransferStatus, CommonConstant.DOC_TRANSFER_STATUS.NO_TRANSFER_APPLY_AND_NO_OUT)
                .setSql("remark = concat('" + remark + "', remark)")
                .eq(StockInventoryDocOccupy::getDocNo, docNo);

        return this.update(updateWrapper);
    }

    @Transactional(rollbackFor = {Exception.class})
    @Override
    public boolean changeDocRecordToTransferAppliedAndOuted(String docNo, ExchangeActionTypeEnum exchangeActionTypeEnum, StockChangeInnerEventEnum stockChangeInnerEventEnum) {
        if(stockChangeInnerEventEnum != null)
            return changeDocRecordToTransferAppliedAndOuted(docNo, stockChangeInnerEventEnum.getCode(), stockChangeInnerEventEnum.getName());
        return changeDocRecordToTransferAppliedAndOuted(docNo, exchangeActionTypeEnum.getCode(), exchangeActionTypeEnum.getName());
    }


    private boolean changeDocRecordToTransferAppliedAndOuted(String docNo, Integer code, String msg) {
        if (StringUtils.isBlank(docNo)) {
            return false;
        }

        String remark = getNewDocRecordRemark(DocOccupyTransferStatusEnum.TRANSFER_APPLIED_AND_OUTED.getCode(), code, msg);

        //将订单下的占用记录调拨状态更新为"调拨已申请并且已出可售仓"
        LambdaUpdateWrapper<StockInventoryDocOccupy> updateWrapper = Wrappers.lambdaUpdate(StockInventoryDocOccupy.class)
                .set(StockInventoryDocOccupy::getDocTransferStatus, CommonConstant.DOC_TRANSFER_STATUS.TRANSFER_APPLIED_AND_OUTED)
                .setSql("remark = concat('" + remark + "', remark)")
                .eq(StockInventoryDocOccupy::getDocNo, docNo);

        return this.update(updateWrapper);
    }

    /**
     * 获取"已下单"状态并且"未占用"且"调拨已申请并且已出可售仓"的单据记录
     *
     * @param docNo
     * @return
     */
    @Override
    public List<StockInventoryDocOccupy> getPlacedAndNoOccupyAndTransferAppliedAndOutedDocRecord(String docNo) {
        if (StringUtils.isBlank(docNo))
            return null;

        //获取"已下单"状态并且"未占用"且"调拨已申请并且已出可售仓"的单据记录
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .eq(StockInventoryDocOccupy::getDocNo, docNo)
                        .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED)
                        .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.NO)
                        .eq((StockInventoryDocOccupy::getDocTransferStatus), CommonConstant.DOC_TRANSFER_STATUS.TRANSFER_APPLIED_AND_OUTED));
    }

    /**
     * 获取"已下单"状态并且"未占用"且"调拨已申请并且未出可售仓"的单据记录
     *
     * @param docNo
     * @return
     */
    @Override
    public List<StockInventoryDocOccupy> getPlacedAndNoOccupyAndTransferAppliedAndNoOutedDocRecord(String docNo) {
        if (StringUtils.isBlank(docNo))
            return null;

        //获取"已下单"状态并且"未占用"且"调拨已申请并且未出可售仓"的单据记录
        return this.list(
                Wrappers.lambdaQuery(StockInventoryDocOccupy.class)
                        .eq(StockInventoryDocOccupy::getDocNo, docNo)
                        .eq(StockInventoryDocOccupy::getStatus, CommonConstant.DOC_OCCUPY_STATUS.PLACED)
                        .eq(StockInventoryDocOccupy::getIsUsed, CommonConstant.YES_OR_NO.NO)
                        .eq((StockInventoryDocOccupy::getDocTransferStatus), CommonConstant.DOC_TRANSFER_STATUS.TRANSFER_APPLIED_AND_NO_OUT));
    }
}




